/**
 * Created by bethinner on 6/6/16.
 */
import React, { Component } from 'react';

import {bindActionCreators} from 'redux'
import { connect } from 'react-redux'
import Link from 'react-router/lib/Link'
import browserHistory from 'react-router/lib/browserHistory'
import NavigationBar from '../components/NavigationBar'
import Card from '../components/Card'
import * as actions from '../actions/actions.js'


export default class StoreListContainer extends Component{
    constructor(props){
        super(props);
        this.state={business_id:this.props.location.state.business_id}
        this.props.storeListFetch(this.props.location.state.business_id);
    }

    componentWillMount(){
        $('#loadingToast').hide();
    }

    render(){
        return(
            <div>
                <NavigationBar Title="门店列表" LeftBar="true"/>
                {this.props.dataList.map((data,index)=>{
                        return (< Card key={index} title={data.store_name}>{data.address}</Card>)
                    }
                )}
            </div>

        )
    }
}

StoreListContainer.defaultProps = {
    dataList: [
    ],
}
function mapStateToProps(state) {
    $('#loadingToast').hide();
    return{
        dataList : state.get('storeList').toJS(),
    }


}
function mapDispatchToProps(dispatch) {
    return bindActionCreators(actions, dispatch);
}
StoreListContainer.propTypes = {
    dataList: React.PropTypes.array,
}

module.exports=connect(mapStateToProps, mapDispatchToProps)(StoreListContainer);
